home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 003 / ff / ff.test < prev    next >
Text File  |  1995-03-17  |  8KB  |  180 lines

  1. #! /usr/local/bin/ksh
  2. # test script for ff fast text formatter
  3.  
  4. PATH=$PATH:/tmp
  5. delim="-------------- "
  6. trap "rm -f /tmp/linelength fourcol ff.in; exit 1" 2
  7.  
  8. # Define utility functions
  9. function runcom
  10.     {
  11.     echo "$delim($1):" "$2"
  12.     shift
  13.     echo $* | sh
  14.     }
  15. function newtest
  16.     {
  17.     echo
  18.     echo $1
  19.     echo ===============================================
  20.     }
  21. # the following must be available to the Bourne shell
  22. echo "dm '#INPUT'" > /tmp/linelength
  23. chmod +x /tmp/linelength
  24.  
  25. # create utility files
  26. cat << \EOF > fourcol
  27. a    b    c    d
  28.     w    x    y    z
  29. EOF
  30. cat << \EOF > ff.in
  31. The rain in Spain falls mainly in the plains.
  32. She sells sea shells on the sea shore. 
  33. Peter piper picked a peck of pickled peppers.
  34. The quick red fox jumped over the lazy brown dog.
  35. A stitch in time saves nine.
  36. Now is the time for all good men to come to the aid of the party.
  37. And now a word from our sponsor...
  38.     
  39. The rain in Spain falls mainly in the plains.  She sells sea
  40. shells on  the sea  shore.   Peter piper  picked a  peck  of
  41. pickled peppers.   The quick  red fox jumped  over the  lazy
  42. brown dog.  A stitch  in time saves nine.   Now is the  time
  43. for all good men to come to the aid of the party.  And now a
  44. word from our sponsor...
  45. EOF
  46.  
  47. newtest "WIDTH WIDTH WIDTH WIDTH WIDTH WIDTH WIDTH WIDTH"
  48. runcom "width of 1"                  "ff -w 1 ff.in | linelength"
  49. runcom "width of 20"                 "ff -w 20 ff.in | linelength"
  50. runcom "width of 60"                 "ff -w 60 ff.in | linelength"
  51.  
  52. newtest "JUSTIFY JUSTIFY JUSTIFY JUSTIFY JUSTIFY JUSTIFY JUSTIFY"
  53. runcom "justify text"                    "ff -j ff.in"
  54. runcom "justify with width = 30"         "ff -w 30 -j ff.in | linelength"
  55. runcom "justify with indent and temp indent"  "ff -j -i 20 -I 5 ff.in | linelength"
  56.  
  57. newtest "ALLTABS ALLTABS ALLTABS ALLTABS ALLTABS ALLTABS"
  58. runcom "tabs set at 1"          "ff -T 1 -b fourcol"
  59. runcom "tabs set at 10"         "ff -T 10 -b fourcol"
  60. runcom "tabs set at 100"        "ff -T 100 -b fourcol"
  61.  
  62. newtest "TABS TABS TABS TABS TABS TABS TABS TABS TABS TABS"
  63. runcom "decreasing values"      "ff -t 10 -t 11 -t 10"
  64. runcom "non increasing values"  "ff -t 10 -t 11 -t 11"
  65. runcom "1 too many values"      "ff -t 1 -t 2 -t 3 -t 4 -t 5 -t 6 -t 7 -t 8 -t 9 -t 10 -t 11 -t 12 -t 13 -t 14 -t 15 -t 16 -t 17 -t 18 -t 19 -t 20 -t 21"
  66. runcom "max number of values - exits from unknown option" "ff -t 1 -t 2 -t 3 -t 4 -t 5 -t 6 -t 7 -t 8 -t 9 -t 10 -t 11 -t 12 -t 13 -t 14 -t 15 -t 16 -t 17 -t 18 -t 19 -t 20 -z"
  67. runcom "huge tab value"         "ff -t 300"
  68. runcom "tab value at extreme"   "ff -t 255 fourcol"
  69. runcom "indented ff -U table"   "ff -U | ff -t 20"
  70. runcom "all plussed values" "ff -t +55 -t +15 fourcol"
  71. runcom "more tabs than tabstops" "ff -t 10 -t +15 fourcol"
  72.  
  73. newtest "UPPER CASE TITLE UPPER CASE TITLE UPPER CASE TITLE"
  74. runcom "all titles"              "ff -u ff.in"
  75. runcom "centered titles"         "ff -cu ff.in"
  76.  
  77. newtest "SPACING SPACING SPACING SPACING SPACING SPACING SPACING"
  78. runcom "24 lines spacing of 10 lines - 217 lines" "series 1 10 | ff -bs 24 | wc"
  79.  
  80. newtest "NUMWIDTH NUMWIDTH NUMWIDTH NUMWIDTH NUMWIDTH NUMWIDTH"
  81. runcom "1 value"                 "ff -N 1 ff.in"
  82. runcom "numwidth = 10"           "ff -N 10 ff.in"
  83. runcom "numwidth 20 centered"    "ff -N 20 -c ff.in"
  84. runcom "numwidth=10 indent=10 width=50 tindent=-5 justified" "ff -N 10 -i 10 -w 50 -I -5 -j ff.in"
  85.  
  86. newtest "NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER"
  87. runcom "number zero lines"       "ff -n /dev/null"
  88. runcom "number centered lines"   "ff -n -c ff.in"
  89. runcom "number 4 spaced broken lines" "ff -s 4 -n ff.in"
  90. runcom "number 3 spaced lines on 23 line pages" "series 1 200 | ff -n -s 3 -b -P 23 | wc"
  91.  
  92. newtest "TINDENT TINDENT TINDENT TINDENT TINDENT TINDENT TINDENT"
  93. runcom "temp indent 5"                   "ff -I 5 ff.in"
  94. runcom "negative temp indent will automatically bump -i option" "ff -I -5 ff.in"
  95. runcom "negative temp indent less than -i option" "ff -I -5 -i 10 ff.in"
  96.  
  97. newtest "INDENT INDENT INDENT INDENT INDENT INDENT INDENT INDENT"
  98. runcom "indent 10"                  "ff -i 10 ff.in"
  99. runcom "indent 50"                  "ff -i 50 ff.in"
  100. #runcom "indent 300 - does not crash but is really tedious" "ff -i 300 ff.in"
  101.  
  102. newtest "HEADSIZE HEADSIZE HEADSIZE HEADSIZE HEADSIZE HEADSIZE"
  103. runcom "1 header size"              "ff -H 1 ff.in | wc"
  104. runcom "100 header size"            "ff -h 'Huge header!!' -H 100 ff.in | wc"
  105. newtest "tricky part can come with even and odd sizes"
  106. runcom "20 header w/out -p option"  "ff -H 20 ff.in | wc"
  107. runcom "odd header size = 19"       "ff -H 19 ff.in | wc"
  108.  
  109. newtest "HEADER HEADER HEADER HEADER HEADER HEADER HEADER"
  110. runcom "nice header"                'ff -h "@$NAME on $TERM@@`date`" ff.in'
  111.  
  112. newtest "FOOTSIZE FOOTSIZE FOOTSIZE FOOTSIZE FOOTSIZE FOOTSIZE"
  113. runcom "1 foot size"                'ff -F 0 -f "Howdy $NAME" ff.in | wc'
  114. runcom "zero foot size without -p"  "ff -F 0 ff.in"
  115. runcom "20 foot size"               'ff -F 20 -f "Howdy $NAME" ff.in | wc'
  116. runcom "19 foot size"               'ff -F 19 -f "Howdy $NAME" ff.in | wc'
  117.  
  118. newtest "FOOTER FOOTER FOOTER FOOTER FOOTER FOOTER FOOTER"
  119. runcom "nice threepart"             'ff -f "@`date`@$NAME@File * Page %@" ff.in'
  120.  
  121. newtest "DELETE DELETE DELETE DELETE DELETE DELETE DELETE"
  122. runcom "delete blank lines - not really blank" "ff -D ff.in"
  123. runcom "delete blank chars - breaking all lines" "ff -bd ff.in | diff ff.in -"
  124. runcom "delete chars then lines"    "ff -Dd ff.in"
  125.  
  126. newtest "BREAKCHARS BREAKCHARS BREAKCHARS BREAKCHARS"
  127. runcom "null break chars"            'ff -B "" ff.in'
  128. runcom "break on T"                  "ff -B T ff.in"
  129.  
  130. newtest "PAGELENGTH PAGELENGTH PAGELENGTH PAGELENGTH PAGELENGTH"
  131. runcom "0dd page length of 19 should imply -p option" "ff -P 19 ff.in | wc"
  132. runcom "ridiculously small page length" "ff -P 1 ff.in | wc"
  133.  
  134. newtest "PAGINATE PAGINATE PAGINATE PAGINATE PAGINATE PAGINATE"
  135. runcom "paginate"                    "ff -p ff.in | wc"
  136.  
  137. newtest "BREAK BREAK BREAK BREAK BREAK BREAK BREAK BREAK"
  138. runcom "break lines + check with diff" "ff -b ff.in | diff - ff.in"
  139.  
  140. newtest "CENTER CENTER CENTER CENTER CENTER CENTER CENTER "
  141. runcom "center all lines"            "ff -c ff.in"
  142. runcom "center on lines 50 wide"     "ff -c -w 50 ff.in"
  143. runcom "center on lines 1 wide"      "ff -c -w 1 ff.in"
  144.  
  145. newtest "BASIC BASIC BASIC BASIC BASIC BASIC BASIC BASIC "
  146. runcom "no options from stdin"       "ff < ff.in"
  147. runcom "no options from stdin -"     "ff - < ff.in"
  148. runcom "no options from ff.in"       "ff ff.in"
  149. runcom "three times: ff.in - ff.in"  "ff ff.in - ff.in < ff.in"
  150. runcom "usage menu"                  "ff -U"
  151.  
  152. newtest "BAD OPTIONS BAD OPTIONS BAD OPTIONS BAD OPTIONS"
  153. runcom "bad option"                  "ff -z"
  154. runcom "bad file"                    "ff howdy pal"
  155. runcom "too many calls to stdin"     "ff - - - < ff.in"
  156.  
  157. newtest "PARSER PARSER PARSER PARSER PARSER PARSER PARSER PARSER"
  158.  
  159. newtest "CHECK OPTIONS CHECK OPTIONS CHECK OPTIONS CHECK OPTIONS"
  160. runcom "center iff no justify"       "ff -cj ff.in"
  161. runcom "break lines iff no justify"  "ff -bj ff.in"
  162. runcom "justify iff not center"          "ff -cj"
  163. runcom "justify iff not breaklines"      "ff -bj"
  164. runcom "justify iff not tabs"            "ff -t 5 -j"
  165.  
  166. newtest "NUMBER OPTIONS NUMBER OPTIONS NUMBER OPTIONS NUMBER OPTIONS"
  167. for numopt in P w T t s N i I H F P
  168. do
  169.     runcom "Missing Value"               "ff -$numopt < ff.in"
  170.     runcom "Bad Type Value"              "ff -$numopt foo < ff.in"
  171.     runcom "Zero Integer"                "ff -$numopt 0 < ff.in"
  172.     runcom "Negative Integer"            "ff -$numopt -1 < ff.in"
  173. done
  174.  
  175. newtest "MISSING ARGS MISSING ARGS MISSING ARGS MISSING ARGS"
  176. for argopt in h f B
  177. do
  178.     runcom "Missing Value"               "ff -$argopt < ff.in"
  179. done
  180.